Fix Cursor agentKv timestamp attribution#345
Open
ozymandiashh wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #325 by removing the remaining Cursor timestamp fallback that could attribute historical usage to the SQLite database modification time.
This is separate from the undated
bubbleId:%path fixed onmain: bubble rows already requirecreatedAt. The remaining risk wasagentKv, where CodeBurn still dated every parsed agentKv session withstatSync(state.vscdb).mtimeMsand fell back tonew Date()if the stat failed.Root Cause
Cursor can modify
state.vscdbfor background maintenance, migrations, or unrelated writes. Using the database filemtimeas the usage timestamp means an old agentKv conversation can be reported as new usage whenever the DB file changes.Concrete example covered by the tests:
agentKvsession contains old user/assistant content.2099-01-01.What Changed
createdAt,timestamp, ortime.state.vscdbmtime or parse time.CODEBURN_CACHE_DIRsupport to the Cursor result cache so tests can isolate cache state from the user's real cache.Relation To #337
#337 invalidates cached results after the undated bubble-row fix. This PR includes the same cache-version/cache-dir hunk because agentKv timestamp semantics also change and v3 caches can contain mtime-bucketed agentKv calls.
If #337 merges first, this PR can be rebased to keep the agentKv parser/tests and drop the duplicate cache hunk if needed.
Validation
npx vitest run tests/providers/cursor-agentkv-timestamp.test.ts tests/providers/cursor.test.ts tests/providers/cursor-bubble-dedup.test.ts tests/providers/cursor-workspace-breakdown.test.ts- 24/24 tests passed.npx tsc --noEmit --pretty false- passed.npm run build- passed.git diff --check- passed.Notes
I did not validate with real local Cursor history and did not include any local project names, prompts, paths, session IDs, usage values, screenshots, or private product details. The proof uses synthetic SQLite fixtures specifically constructed to reproduce the timestamp-attribution failure mode.
The intentional tradeoff is that legacy agentKv rows without any internal timestamp are skipped. That is safer than reporting historical usage under the wrong day.